<template>
	<view>
		<view class="cont">
			<view class="ites">
				<view class="tit">需求标题（100字以内）</view>
				<view class="tit_c">
					<input v-model="params.title" type="text" placeholder="请输入需求标题"/>
				</view>
			</view>
			<view class="ites">
				<view class="tit">需求详情（500字以内）</view>
				<view class="tit_cs">
					<textarea   v-model="params.content"  maxlength="500" placeholder="请输入需求详情"></textarea>
				</view>
			</view>
			<view class="ites">
				<view class="tit">联系人姓名</view>
				<view class="tit_c">
					<input v-model="params.userName" type="text" placeholder="请输入联系人姓名"/>
				</view>
			</view>
			<view class="ites">
				<view class="tit">联系人电话</view>
				<view class="tit_c">
					<input v-model="params.userPhone" type="number" placeholder="请输入联系人电话"/>
				</view>
			</view>
		</view>
		<view class="btn">
			<view class="btns" @click="tj">立即发布</view>
			<view class="btn_text">请勿发布虚假信息、不良信息，违者轻则封号，重则追究法律责任</view>
		</view>
	</view>
</template>

<script>
	import { getneed} from '@/common/http.api.js';
	export default {
		data() {
			return {
				params:{
					title:'',
					content:'',
					userName:'',
					userPhone:'',
				}
			};
		},
		methods:{
		   tj(){
			   if(this.params.title == ''){
			   	uni.showToast({
			   		title: '请输入发布标题',
			   		duration:2000,
			   		mask:false,
			   		icon:"none"
			   	})
			   }else if( this.params.content == ''){
			   	uni.showToast({
			   		title:'请输入发布内容',
			   		duration:2000,
			   		mask:false,
			   		icon:"none"
			   	})
			   	
			   }else if(this.params.userName == ''){
			   	uni.showToast({
			   		title:'请输入联系人',
			   		duration:2000,
			   		mask:false,
			   		icon:"none"
			   	})
			   }else if(this.params.userPhone == ''){
			   	uni.showToast({
			   		title:'请输入联系人电话',
			   		duration:2000,
			   		mask:false,
			   		icon:"none"
			   	})
			   }else{
				  getneed(this.params).then(res=>{
					 uni.showToast({
					 	title:'发布成功',
					 	duration:2000,
					 	mask:false,
					 	icon:"none"
					 })
					 setTimeout(()=>{
						 uni.navigateBack()
					 },1000)
				  }) 
			   }
			  
		   }	
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F0F0F1;
	}
	.cont{
		background-color: #fff;
		width: 704rpx;
		margin: 20rpx auto;
		border-radius: 10rpx;
		padding: 10rpx 20rpx 40rpx;
		box-sizing: border-box;
	}
	.ites{
		margin: 40rpx 0rpx 0rpx 0rpx;
	}
	.tit{
		font-size: 30rpx;
		color: #000000;
		font-weight: bold;
	}
	.tit_c{
		width: 100%;
		border: 1px solid #eeeeee;
		height: 80rpx;
		border-radius: 10rpx;
		margin-top: 14rpx;
		input{
			line-height: 80rpx;
			height: 80rpx;
			padding-left: 10rpx;
			font-size: 28rpx;
		}
	}
	.tit_cs{
		width: 100%;
		margin-top: 14rpx;
		textarea{
			width: 100%;
			border-radius: 10rpx;
			height: 340rpx;
			border: 1px solid #eeeeee;
			padding: 10rpx;
			font-size: 28rpx;
			box-sizing: border-box;
		}
	}
	.btn{
		width: 704rpx;
		margin: 100rpx auto;
		.btns{
			width: 640rpx;
			height: 80rpx;
			background-color: #022B5F;
			color: #fff;
			border-radius: 40rpx;
			line-height: 80rpx;
			text-align: center;
			margin: 40rpx auto;
		}
		.btn_text{
			color: #101010;
			font-size: 24rpx;
		}
	}
</style>
